Adjusting products with compensatory elements using a digital twin: Model and methodology

The article presents a novel strategy for reducing the geometric error of a vehicle headlamp equipped with a set of calibration screws, which represents a product assembly. Using a general method for designing and implementing a digital twin, we determined the optimal configuration for a compensatory element that minimizes the total geometric error. Formulated as a problem of constrained minimization, we solved the error using the gradient method and the Broyden–Fletcher–Goldfarb–Shanno method. Products are automatically adjusted according to this optimal setting during the manufacturing process. The results of this novel method indicate that all points can be aligned when the non-individual calibration satifies a geometrical specification of 92%. The digital twin approach was compared to the manufacturing process on 84,055 samples. Overall, 98.19% of the samples were perfectly aligned.


Introduction
As industrial fields diversify and emerge, customers are placing greater demands on producers to continually improve manufacturing processes [1]. Improving manufacturing today requires significant transformation in many processes and the application of new and modern strategies, for example the conceptual changes delivered by Industry 4.0. The article describes a novel process for adjusting calibration screws in a vehicle headlamp. The target product is protected under a Non-Disclosure Agreement, therefore the paper describes a headlamp model with general parameters only instead of the specified headlamp model. All the experiments presented in this paper applied a general kinematic model to suitably illustrate the calibration method.
The target product has a defined set of testing points on its surface. These are used to verify whether the customer's requirements for accuracy are satisfied. Equipped with compensating elements in the form of calibration screws, the product allows minor adjustments to its fixing. During production, the calibration screws must be set so that the resulting geometric error at the testing points is minimized.
In the traditional approach, one produced part per day is taken from a production line and precision adjusted manually by an operator with a screwdriver and measured with a coordinate measuring machine (CMM). The same setting for the calibration screws is then applied to every part manufactured on that day, and consequently the geometric error in each part, in theory, is identical. Quality control applies a statistical process control (SPC) method to calculate the process capability index, which is a statistical measurement that represents the ability to make a product within the specification tolerances (see [2]). The traditional method for calibrating the product is time-consuming, and the calibration screws could also not always be set individually.
The main contributions in this paper are as follows: 1. A novel method for automatically adjusting the compensatory elements of individual headlamps directly in the manufacturing process.

2.
A practical configuration for a digital twin to geometrically calibrate assemblies that use adjustable compensatory elements measured directly for accuracy.

A comparison of two optimization algorithms (gradient method and Broyden-Fletcher-
Goldfarb-Shanno) used on the digital twin.
The challenges inherent in obtaining optimal adjustments calls for the use of a digital twin and to simulate the adjustment process virtually for specific calibration screw settings. This approach allows minimization of the locally Lipschitz continuous composite cost function, which in our case is continuously differentiable and subject to inequality constraints. For this purpose, we can use a method suitable for smooth, unconstrained optimization, for example first-order or second-order methods, where the inequality constraints are subject to a quadratic penalty. The solution proposed in this paper applied the gradient method (first-order method) and Broyden-Fletcher-Goldfarb-Shanno (BFGS) algorithm (second-order method) [3][4][5][6][7]. Fig 1 shows a block diagram of the optimal adjustment procedure using a digital twin. First, an assembled part is measured during the manufacturing process, and then the set of measured points is transferred to a digital twin to simulate the actual geometric parameters. An optimization algorithm then estimates the calibration screw settings and transfers this information to the digital twin. The digital twin thus enables virtual adjustment and calculates the position of the control points, which are subsequently passed to a cost function.
In this case, the cost function consists of two separate functions: inner and outer. The inner function is formulated as an implicit nonlinear vector function that describes the product's kinematic model. This implicit function assigns the testing point locations dðsÞ to the arbitrary locations of the calibration screwss. The outer function is a sum of two functions: the first function evaluates the quality of the adjustment to the product, the second is a quadratic penalty function which penalizes any violation of inequality constraints. The inequality constraints ensure that the set of prescribed limits (tolerances) for testing point locations is not exceeded.
To solve the optimization problem, we applied the gradient method and BFGS algorithm. The optimization algorithm provides a calibration screw setting for the minimum total geometric error and transfers it to the production line. The product is subsequently adjusted according this optimal setting with electronic screwdrivers.
The remainder of the paper is organized as follows. Related works provides an overview of the state of the art. In Methods, we mathematically describe the gradient method, BGFS algorithm and quadratic penalty method. The Models section presents the mass, digital twin and optimization models. Experiment describes the experimental procedure. In Results, we report the experimental results, followed by a discussion of these results in the Discussion section. Finally, we assess the paper's body of knowledge and outline options for future work in the Conclusion.

Related works
Most automotive parts are manufactured on production lines. Generally, they should be manufactured very precisely according to a geometrical specification to facilitate the assembly process. To fulfil quality control standards [8], all products or selected samples must be measured. The most accurate measurements are done with a CMM [9]. Unfortunately, these machines have several limitations, such as limited dimension range and a long measurement cycle [10]. Especially Considering the long measurement cycle, CMMs are especially unsuitable for checking all aspects on a part. A promising method for measuring parts is inline measurement [11], performed directly on the production line.
Quality control checks apply the Geometrical Product Specifications (GPS) defined by the International Organization for Standardization (ISO). GPS provides the exact definitions for the geometry of components in a product so that producing technical drawings, programming measurement instruments, and estimating measurement uncertainties are unambiguous. GPS characterizes the duality principle by defining the non-ideal surface model of a work piece and defining the verification model according to the verification process executed by the person who inspects the manufactured work piece [12]. The difference between the models indicates a measurement uncertainty [13].
Quality control itself does not increase the manufacturing precision, it only estimates a total geometric error. Research challenges lie in improving production processes for more precise manufacturing. Several options are available generally to increase product precision according to GPS. The first option is to calibrate a production line and its robot manipulators using a CMM and the method presented in [14]. Another option for calibrating robot manipulators is using af laser tracker [15]. This method is suitable for a machine tool which can be modelled as serial manipulator with individual axes behaving as rigid bodies with six degrees of freedom.
The second option is to equip a product with compensating elements such as adjustment screws. This allows the adjustment of fixing points in assembled parts to reduce geometric error. Compensating elements such as these are provided by the Böllhof company [16]. Using special mechanical fixing screws, Böllhoff's Flexitol solution permits manual and automated infinitely variable tolerance compensation.
The modern approach to maintaining individual production is a digital twin [17]. The term digital twin has gained popularity recently in academic and industrial circles [18]. A digital twin is a set of virtual information constructs which fully describe the possible or actual physical manufactured product from the micro-atomic level to the macro-geometric level [19,20]. At its optimum, any information that could be obtained by inspecting a physically manufactured product can be derived from its digital twin [19]. In the study presented here, the principle of a digital twin was used to obtain the highest geometric quality for the self-adjusting smart assembly line described in [21]. Table 1 summarizes the works related to the proposed solution. The literature review suggests that the commonly applied approach is calibration of the production line using robot manipulators to achieve higher quality products. Interestingly, quality control is never discussed in any of the reviewed literature. The proposed solution uses Böllhoff Flexitol fixing screws [16] to adjust the fixing points in a product and thereby decrease the total geometric error. Inline measurement allows each part to be measured, a procedure which has a significant impact on the Process Capability Index [25]. Instead of using SPC, the Process Capability Index can be evaluated with each part.

Methods
This section investigates the following type of unconstrained problem: where f : R n ! R is a continuously differentiable function in O.
Let us apply the following notation: x T denotes the transpose of the column vector x and E denotes the identity matrix.
To solve the problem (1), we introduce two iterative optimization algorithms, starting with the gradient method, which represents a first-order method, then a second-order method called the Broyden-Fletcher-Goldfarb-Shanno (BFGS) algorithm. Both methods need a value of f and a gradient of f at every given point x.

Gradient method
First, let us attempt to solve the problem (1) using a descent direction to reduce the value of f.
The gradient method is a special variant of the descent direction method based on the observation that f decreases the quickest if we follow the direction of the opposite gradient. For more detailed information about the method, see [3,4]. The method is still widely used across many scientific disciplines, see for example [26,27].
We start with an initial guess x 0 . The algorithm produces a sequence of iterations x 1 , x 2 , . . .. In every iteration x k , the algorithm evaluates rf(x k ) and finds the descent direction d 2 R n , in the following manner: A new iteration is acquired by moving x k in the direction d, i.e.
The algorithm continues searching until kx k+1 − x k k � ε, where ε is a given precision. The pseudocode of the gradient method is described in Algorithm 1.
take t � > 0 {we consider t � that guarantees the reduction of f} 4: To find the optimal step length t � , we use the descent direction and compute a local minimum of f in the direction d, where For practical computation, it is easier to turn (4) into a constrained problem: where t max is sufficiently large.
For the one-dimensional constrained optimization of f with respect to t, we use the Golden Section method (see [3]).

BFGS algorithm
The Broyden-Fletcher-Goldfarb-Shanno (BFGS) algorithm introduced here is based on Newton's method. It is a second order method using a quadratic model of f in the neighbourhood of x k , i.e.
We want to find a minimum of m k , i.e. find x as a stationary point of m k , The stationary point is labelled x k+1 . From (6), we obtain an expression of Newton's iteration where .
is the Hessian of f. We can denote Moreover, if the Hessian is a positive definite matrix, i.e.
The BFGS algorithm is introduced here is a method which uses Newton's step. In contrast to Newton's method, the Hessian is approximated using the results of the previous iterations, known as a Quasi-Newton's method. A detailed introduction of the method can be found in [4,7]. Even today, the algorithm is used in many scientific fields, see for example [28,29].
The approximation H k of the Hessian r 2 f(x k ) is computed as follows: where y = x k − x k−1 and s = rf(x k ) − rf(x k−1 ). The pseudocode of the BFGS algorithm is described in Algorithm 2.
if y T s > 0 then {if the Hessian is positive definite} 8:

Quadratic penalty method
For the purposes here, we need to minimize f(x) subject to inequality constraints. We solve the following constrained problem: where f and g are continuously differentiable. To apply the algorithms introduced above, we need to approximate our constrained problem (9) with an unconstrained problem. We apply a Quadratic Penalty method to approximate the original solution with a solution to the following: min x2R n f r ðxÞ; For large ρ, the approximate solution cannot be far from the solution of the original problem. Furthermore, for ρ ! 1, the solution of (10) is also a solution of (9).

Models
This section introduces a mathematical model for the digital twin and describes the mass, kinematic model and optimization models in detail.
To indicate points, we use capital letters and two types of index. The upper index refers to the index of the point, the lower index represents the coordinate. The vector which describes the positions of the calibration screws is denoteds.

Mass
Headlamps must fulfil GPS and consist of a housing and glass glued together. Gluing is a possible source of imprecision if the glass is inaccurately positioned. To check the quality, we measure the the geometric dimensions. The product's specification defines a set of test points and vectors. Each vector of the set defines the direction of a measuring sensor.
The specification also defines the constraint points fixed to or supported in the product. The set of test points and vectors and set of constrained points provide the basis for the digital twin. In this study, we define the following types of fixing: • Calibration screw-this fixation type has three degrees of rotational freedom. It can be adjusted (and fixed) along a specific vector, and the remaining perpendicular directions provide the next two degrees of freedom.
• Spike-this fixation type has three degrees of rotational freedom and another degree of freedom in a specific vector (straight line). The spike is a point to line constraint.
• Ball bearing-this fixation has only three degrees of rotational freedom. Other movements are not possible.
• A propped point-this fixation type has three degrees of rotational freedom. Movement is restricted to a plane, or specifically, the propped point slides along a plane surface.

Digital twin
The following section mathematically describes the constraint points. Using a digital twin, we simulated kinematic behavior. The digital twin allows adjustment of the the screws in virtual space and substitutes an approach involving a complicated procedure by an operator who attempts to find an optimal calibration screw setting with a screwdriver and CMM. This section describes the mathematical formulation of the kinematic model which represents the digital twin.
The main idea behind this approach is the assumption that a headlamp is a rigid body and that if we consider the distances between pairs of points and other aspects given by the constraint points, we can obtain a system of equations to describe the object.
We assume that the distances remain constant. For a givens representing the position of the calibration screws, we can compute the shift δ at all test points as a solution of a system of nonlinear equations. The system is represented by the following expression: For the small values ofs that we are interested in, the system F is nearly linear. We can therefore obtain an approximation of δ ins as a solution of where J F is a Jacobian matrix of F with respect to δ, i.e.

PLOS ONE
Adjustment of products with compensatory elements using digital twin: Model and methodology Furthermore, we can take δ 0 = 0 and obtain Let us now describe mathematically the constraint and the test point shifts and specify the elements of δ.
• Calibration screw S-in general, S is screwed in a direction parallel to one of the axes. Movement in the other two coordinates is free. For example, if we decide to screw in the z direction, the location of S after transformation is described as • Spike T-this type of point shifts only in the prescribed direction n T ¼ ðn T 1 ; n T 2 ; n T 3 Þ. The position after transformation is described as • Ball bearing (or fixed point) K-this type of point has no degrees of freedom, and its position after transformation remains the same • Propped point P d -this point must belong to a plane ρ defined by a given normal vector n r ¼ ðn r 1 ; n r 2 ; n r 3 Þ. For (P d ) 0 2 τ, it must be true that • Test point P i -the point has generally no defined limits in terms of shift or rotation. Its position after transformation is described as The test point positions and the shifts δ i play a key role in the optimization problem introduced in this article.

Optimization model
The aim of the method is to find the optimal configuration of the calibration screws S 1 , S 2 , . . ., where the distances between test points P i and their prescribed locations P i prec are minimal. Regarding the technical aspects, we cannot use the Euclidean norm to compute k P i P i prec k and must develop a more complex method.
For each test point, we have a sensor B with an approach vectorm ¼ BP �! i prec . The point B and vectorm determine the line p.
We construct a plane ρ perpendicular to p containing the point P i and find the point P i pr as an intersection of p and ρ. We then define the desired distance as This is illustrated in Fig 2. We solve the following constrained optimization problem with the set of constraints related to the distances k P i P i prec k B , d i ðsÞ is a vector describing the shift of the point P i depending ons, and w i represents the weight of P i . In other words, the value w i indicates the importance of aligning P i near the ideal position. Let us specify that our task is to solve the problem of quadratic programming with nonlinear inequality constraints. We apply the Quadratic Penalty method introduced above and transform (12) into an unconstrained problem where a i ðsÞ ≔ max This type of problem can be solved using either of the optimization methods introduced above. Considering the properties of the cost function, it can also be shown that the gradient method converges linearly to the minimum. The convergence of the BFGS algorithm is superlinear.

Experiment
In this section, we provide an example of a design for a digital twin and formulate the kinematic model of a headlamp and application of the optimization algorithm.

Data
For the numerical experiments, we considered a model with the following specification: • Two calibration screws S 1 and S 2 -both are screwed in the z direction, while movement in the other directions is free.
• A spike T-this point shifts only in the direction defined by a vectorñ T .
• Two propped points P d1 and P d2 -both points must remain in the given planes defined by normals n r 1 and n r 2 .
• The headlamp does not contain any ball bearings.
We also considered the set of test points P i , i 2 {1, . . .n} that we would like to align to an optimal position.
If we consider all the model's properties, we obtain a vector of unknowns: where the first 11 elements relate to shifts in the constraint points and the remaining 3n elements describe the transformation of the test points needed to evaluate the cost function. It must be true that the distance between each pair of points remains constant. For a givens ¼ ðs 1 ; s 2 Þ, let us formulate the system of equations which define our kinematic model. First, we take into account the distances between the test points and constraint points; a prime symbol denotes the points after transformation. We thus obtain n equations in the following form: The previous equations can be modified to Consequently, we can focus on a combination of test points and both calibration screws and obtain another 2n equations: The last coordinate of S i is equal to s i , which is given. The propped points belong to given planes and are described by the following two equations: P d1 2 r 1 : P d2 2 r 2 : The points must also be a constant distance from the spike and both calibration screws. Therefore, and we obtain another 8 equations. The final three equations reflect the distances between pairs of constraint points.
We can rewrite Eqs (17)- (24) in the same manner as Eq (15). Finally, we obtain a system of equations that can be written as where F : R q ! R q , q = 3n + 11 is a vector function. Each component of this function is defined from Eqs (15), (17)-(24) (e.g., the first component of the vector function F is defined by the left side of Eq (16)). As mentioned above, we exploit the system's approximately linearity for small values of s 1 , s 2 and compute δ from where J is a matrix of the first derivatives of F with respect to all variables in δ.

Gradient and BFGS method
The methods introduced here are designed for unconstrained optimization. For each given vectors, we need to evaluate the cost function (13) and compute the gradient.

Simple model example
Let us now illustrate the previous relationship which describes the kinematic model of the headlamp and application of the optimization algorithms on a simple model. The model in this example contains only one calibration screw S, one spike T, one propped point P d , and one test point P and its prescribed location P prec .
The specification in the given model is as follows: • • Test point P = [0, 0, 1], which we want to adjust to the optimal position P prec = [0, 0, 2].
The model is illustrated in Fig 3. For this simple model, we obtain the following vector of unknowns: where the first three unknowns relate to shifts of the constraint points, and the remaining three unknowns describe the transformation of the test point we need for evaluating the cost function.
Let us now describe the kinematic model for this example, obtained in the same manner as the system of Eq (25).

PLOS ONE
We formulate the system of equations for the model (a prime symbol denotes the points after transformation) Finally, we obtain a system of equations that can be written as where F : R q ! R q , q = 6 is a vector function. Each component of this function is defined by the left side of Eqs (32)-(37). Eq (38) is solved using the expression in (26). Now let us consider the optimization problem describing the calibration of screws during headlamp adjustment. For simplicity, in this example, we do not require a given tolerance to be satisfied for the test point P, i.e., we consider only the unconstrained optimization problem.
For this example, we obtain the following optimization problem: The analytical solution to the problem iss ¼ 1. Algorithm 3: Description of the calibration procedure 1: A headlamp is placed onto a mounting stand by an operator. 2: A shelf with a stand is transferred to a calibration area. 3: Robotic arms and tactile sensors perform precise measurement. 4: The digital twin calculates optimal calibration screw settings. 5: Automated screwdrivers set the target screw settings. 6: A protocol with estimated tolerances is stored in the database.
An iteration of the optimization method for headlamp adjustment is explained schematically in Fig 4. Algorithm 3 indicates the entire procedure for the calibration process of one headlamp on a deployed machine.

Results
For the numerical experiments, let us consider the headlamp introduced in the previous section, with two calibration screws S 1 and S 2 , two propped points, one spike, and 25 test points. Both S 1 and S 2 can only be screwed in the z direction. At every test point, we are given a tolerance, i.e. a maximum permitted distance from the prescribed position. Note that the distance is measured in the k.k B norm defined above.

PLOS ONE
Adjustment of products with compensatory elements using digital twin: Model and methodology the behaviours of the algorithms. It also provides an easy way to verify the output of the algorithm.
We then applied the same conditions as in the previous simulation, but after transformation, slightly adjusted the test points using shifts. This procedure simulated an imperfect manufacturing process or glass imprecisely glued to the housing.
The final simulation modelled an ideal headlamp and moved it into an initial position. Unlike the previous simulation, the product was transformed using general shifts and rotations. The optimization algorithm then calculated an optimal position.
The combination of the previous two approaches reflects the real conditions of a headlamp not having an ideal shape.
All experiments were solved with the starting points 0 ¼ ð0; 0Þ and a stopping point: the ideal headlamp was adjusted using general transformations and a stopping point of ε = 10 −6 ; the real headlamp was adjusted according to the kinematic model and a stopping point of ε = 10 −3 ; the ideal headlamp was adjusted using a penalty coefficient ρ = 10 12 and a stopping point of ε = 10 −2 . These parameters were tuned according to the type of adjustment. These stopping point values are sufficient due to the accuracy achieved in the calibration screw settings by the industrial robot performing the adjustment.

Ideal headlamp adjusted according to the kinematic model
For the numerical experiment, we sets ¼ ð0:4; 0:1Þ and transformed all points according to (11). The aim was to determine the screw settings that aligned the model into an ideal position.
We then applied both algorithms and compared the results. The gradient method produced the outputs grad out ¼ ðÀ 0:414042806; À 0:098633275Þ, and the BFGS algorithm returned the vectors BFGS out ¼ ðÀ 0:414042804; À 0:098633323Þ. With a precision set to 10 −6 in both algorithms, the number of decimal places was raised accordingly. Both results corresponded to the expected solution.
We are interested in comparing the distances between the test points and their prescribed positions before and after adjustment. Fig 6 compares the k.k B norm with the given tolerance, which is indicated by a red line. Some points in the initial position fell outside the given tolerance. By contrast, after optimization, the headlamp fully satisfied the specified conditions, and distances were reduced significantly. Namely, the mean of the distance before adjustment was 1.91�10 −1 , and the mean of the final distance was 3.50�10 −3 . The value of the cost function at the beginning of the optimization was 4.34. Both algorithms reduced the value to 8.01�10 −4 .
We are also interested in the performance of the algorithms. Fig 7 indicates that the gradient method needed significantly fewer iterations to reduce the cost function. However, the Golden Section method applied in this algorithm is more time-consuming.
The results in Table 2 give us a better idea of the behaviour of the algorithms and various configurations for the calibration screws.

Real headlamp adjusted according to the kinematic model
In this case,s ¼ ð0:4; 0:1Þ again and all points were transformed according to (11). We then slightly deformed the test points, resulting in the initial model that we want to adjust and return to the prescribed position.
First, imprecise manufacturing was simulated by adding noise to all test points. Initially, several points fell outside the given tolerance, but after optimization, all points were completely within tolerance. The mean of the distance before adjustment was 1.92 � 10 −1 , and the mean of the final distance was 1.33 � 10 −2 . The value of the cost function was reduced from 4.33 to 1.39 � 10 −2 .
The next experiment simulated an error created by imprecision in the gluing process. For this simulation, we adjusted all points located on the glass 0.01 mm in the z direction. This

PLOS ONE
Adjustment of products with compensatory elements using digital twin: Model and methodology adjustment caused several points to fall outside the given tolerance, but after optimization all test points completely satisfied the tolerance. The mean of the distance before adjustment was 1.92 � 10 −1 , and the mean of the final distance was 9.40 � 10 −3 . The value of the cost function was reduced from 4.36 to 5.57 � 10 −3 . Fig 8 indicates the distances k.k B before and after transformation in relation to the given tolerance, shown as a red line for both of the experiments above. Since the given tolerance for each test point was different, we scaled all tolerances to one and scaled the distances in the same manner. We observed a significant reduction in the distance of the test points from their prescribed positions after adjustment.

Ideal headlamp adjusted using general transformations
In this case, an ideal headlamp was modified with general shifts and rotations. This approach reflects practical situations more realistically and tested the robustness of the algorithms.
First, a rotation of 10 −2 π on the x axis was applied. The aim is to find a position for the calibration screws which compensates the rotation. The mean of the distance before adjustment was 5.14�10 −1 , and the mean of the final distance was 2.55�10 −1 . The value of the cost function was reduced from 12.03 to 4.67.
Consequently, the rotation according to the y axis by 10 −2 π was applied. The mean of the distance before adjustment was 3.71�10 −1 , and the mean of the final distance was 2.15�10 −1 . The value of the cost function was reduced from 8.59 to 4.52.
We then rotated the model around the x and y axes by 10 −2 π. Fig 9 illustrates the effect of both rotations and the distances k.k B . The mean of the distance before adjustment was 5.03�10 −1 , and the mean of the final distance was 2.52�10 −1 . The value of the cost function was reduced from 9.32 to 5.95.
The model is very sensitive to rotation and it is easy to violate the mathematical conditions. However, both algorithms were able to adjust all the test points within the given tolerance.  Let us now focus only on shift along the vector (0.3, 0.3, 0.5) mm. The mean of the distance before adjustment was 5.09�10 −1 , and the mean of the final distance was 3.61�10 −1 . The value of the cost function was reduced from 8.71 to 5.98.
Finally, we combine rotation and shift. We take both angles equal to 1 3 � 10 À 2 p and the vector (0.05, 0.05, 0.05) mm. The mean of the distance at the start was 5.09�10 −1 , and the mean of the final distance was 2.47�10 −1 . The value of the cost function was reduced from 9.41 to 4.95. Fig 10 shows the distances k.k B before and after the transformation in relation to the given tolerance, which is indicated with a red line for all five experiments above. Since the given tolerance for each test point was different, we scaled all tolerances to one and scaled the distances in the same manner. We observed a reduction in the distance of the test points from their prescribed positions after adjustment.

Comparison to manual calibration by an operator
The proposed method has been successfully applied to the production line of an automotive manufacturer. In this section, we compare the proposed method (individual calibration) to manual calibration by an operator (non-individual calibration).
In manual calibration, when production commences, the first headlamp produced is taken and precisely measured using a CMM. An operator then manually and expertly estimates the optimal calibration screw setting. All subsequent headlamps adjusted on the same day are considered as having the same geometry, shape, and initial position as the reference headlamp. The same calibration screw setting is therefore used for every product produced on that day. The calibration procedure itself is non-individual and done by the operator using an industrial robot.
The proposed method achieves a major improvement in the success rate of adjustment. It is able to respond to the changes in shape and position and adjust settings accordingly. A minor disadvantage is the additional time needed for measurement and the adjustment procedure. Each headlamp on the line is checked, measured and adjusted, and compared to manual adjustment, the positions of the calibration screws can be computed very precisely for each part.

PLOS ONE
The products are considered slightly deformed and adjusted along the vector t = (0.1, 0.1, 0.2). Using the optimization algorithm, the optimal positions opt of the calibration screws is computed. To test the system, we used a set of 20 test samples with random noise added to each point and applied the vector t. To simulate the original method, all samples were adjusted according to the same calibration screw settings opt . Table 3 shows the results for both approaches obtained by the computer simulation and the original position before adjustment. The reference product is highlighted in grey. Fig 11 compares non-individual and individual calibration with non-calibrated samples. Headlamps with no calibration indicate the highest inaccuracies and only 56% are within tolerances. Non-individual calibration produced better results with 92% of samples within tolerances. All individually calibrated samples were within tolerances and obtained slightly smaller distances.

Comparison of digital twin with the manufacturing process
To evaluate the digital twin, we compared the predicted adjustment according to the digital twin and the results obtained from a practical run. The evaluation procedure differs from the manufacturing process in that a part is measured only once, specifically before calibration. This is due to the strict requirements in the machine cycle where post-calibration measurement cannot be performed. Fig 12 indicates the relative error between estimated tolerances according to the digital twin and experimental measurements by the CMM. Relative error  relates to the maximum tolerance at each point, calculated as follows: where Err REL is the relative error, X EST is the tolerance estimated from the digital twin, X CMM is the tolerance measured by the CMM, and Toler is the maximum tolerance permitted for a particular point. Fig 12 indicates that the relative error does not exceed 12%, which means, for example, all points with a tolerance of 1 mm have a maximum absolute error of 0.12 mm. Table 4 gives a breakdown of the digital twin's success in adjusting a specific headlamp type in a practical industrial scenario. The source data set were obtained from an industrial partner and represent the results of the digital twin calibration process performed directly on a manufacturing line. The dataset describes 84,055 fully measured headlamps before calibration and the number of points outside tolerances after calibration according to the digital twin.
From 84,055 fully calibrated samples, 98.19% and most of the remaining (1.59%) samples were produced with few inaccuracies. A breakdown is given for the input samples according to four inaccuracy levels. Input samples at the zero (0) level indicated no points outside tolerances, representing 14.39% of all production; these were adjusted simply to improve their geometrical properties. After calibration, almost all of these samples showed zero inaccuracies, only eight samples indicating a few points outside tolerances. Input samples at the next level (1-4) represented 53.77% of production and contained a small number of inaccuracies. After calibration, 98.61% of these samples showed no points outside tolerances. The majority of the remainder had few inaccuracies (low), and eight samples had slightly more (medium). At the next level (5-10), input samples represented 30.53% of production and contained significant numbers of inaccuracies. The calibration process improved these samples to 97.32% with no points outside tolerances. Input samples at the (high) level of inaccuracy represented a minor portion of production (1.31%); the calibration procedure in this case was able to fully calibrated 81.87% of samples.

Discussion
Several interesting topics can be discussed, the first being the optimization methods introduced in the article. The industrial partner required quick computation and high accuracy, and to investigate, we selected a first-order method (gradient method) and quasi-Newton method (BFGS algorithm). The experiments revealed that the BFGS algorithm is quicker than the gradient method.
Compared to the zero-order method, it is necessary to evaluate the gradient of the cost function. However, the proposed methods required significantly less time to find a solution. Theoretically, second-order methods converge even more quickly than quasi-Newton methods, but unfortunately, it is very difficult to compute the Hessian in every iteration. Table 5 provides a general overview of the proposed approach compared to two state-ofthe-art methods. Both of the state-of-the-art methods are more versatile than the proposed solution, however they permit only basic transformations (translation and rotation) and do not include any additional constraints. The proposed method can be applied to a specific product only, but it incorporates more complex transformations (with calibrations screws), includes constraint points, and allows a priority and limits to be set for each test point. Moreover, the proposed method has a guaranteed convergence and shorter computational time: computation speed was one of the industrial partner's main requirements.
Finally, we outline possible future modifications to the proposed automated product adjustment and calibration screw method. Thus far, we have worked with the assumption that the product behaves as a rigid body and that no friction exists between the calibration screws and the product. We also regard the problem as static and independent of time. The adjustment process does not depend on the screwing sequence. In the future, it may be necessary to modify the kinematic model to describe a product as an elastic body. In this case, the kinematic model will require modification and use finite element methods. Another possible modification is to consider the friction between the calibration screws and the product according to the Coulomb model of friction, for example. In this article, we neglected friction. If we consider friction, both the kinematic model and optimization algorithm would need to be redesigned since the cost function would no longer be continuously differentiable, only Lipschitz continuous. For this reason, a method which is suitable for minimizing a function that is not differentiable should be used. These types of method are called non-smooth methods; one of the most commonly applied is the bundle method. A detailed discussion about using the bundle method for this type of problem is in [31,32]. It may also be necessary to model the adjustment process as dependent on time so that the correct screwing sequence is considered and maintained.

Conclusion
The article introduced a digital twin model for automated product adjustment using calibration screws. The automated product adjustment procedure was designed to find the optimal configuration for a set of calibration screws to minimize the distances between the test points and their prescribed positions and therefore eliminate geometric error. The proposed strategy consists of solving two sub-problems: the design of a digital twin for a headlamp and optimization using calibration screws.
We formulated an optimal product adjustment procedure for minimizing the locally Lipschitz continuous cost function, which in this case is continuously differentiable and subject to inequality constraints. To solve the optimization problem, we applied the gradient method and BFGS algorithm. The body of knowledge presented in the article contains a novel strategy for precisely manufacturing headlamps using a digital twin. Headlamps are equipped with compensatory elements that can adjust the fixing points of the product. Before we applied the proposed automated adjustment method, only one headlamp per day was measured and adjusted manually by a machine operator. The remaining products were adjusted according to the same settings throughout the day by a machine. The main advantage of the proposed method is its ability to adjust each part with individual settings and thereby reduce production variability. Its second advantage is in process capability: the manufactured part is measured during the adjustment process, yielding final tolerances. This feature has an enormous impact on the Process Capability Index. Tolerances only need to meet the customer's specification limits instead of the stricter tolerances applied in the SPC strategy.
The results showed that the novel method was able to align all headlamps, whereas nonindividual calibration is able to aligns only 92% of parts. The digital twin method was applied to 84,055 headlamps samples, yielding successfully alignment by the calibration machine in 98.19% of samples.